/* GUI CONVERTED from rspm.p (converter v1.75) Thu May  3 03:10:30 2001 */
/* rspm.p - SCHEDULE CONTROL MAINTENANCE                                    */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                      */
/* All rights reserved worldwide.  This is an unpublished work.             */
/* $Revision: 1.12 $                                                     */
/*V8:ConvertMode=Maintenance                                                */
/* REVISION: 9.0    CREATED    : 10/25/98       BY: *K1QZ* Suresh Nayak     */
/* REVISION: 9.0   MODIFIED    : 03/13/99       BY: *M0BD* Alfred Tan       */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KP* myb                */
/* REVISION: 9.1      LAST MODIFIED: 09/11/00 BY: *N0RT* BalbeerS Rajput    */
/* $Revision: 1.12 $    BY: Kaustubh K.    DATE: 04/27/01 ECO: *P00K*    */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */
/*                                                                          */
/*         THIS PROGRAM IS A BOLT-ON TO STANDARD PRODUCT MFG/PRO.           */
/* ANY CHANGES TO THIS PROGRAM MUST BE PLACED ON A SEPARATE ECO THAN        */
/* STANDARD PRODUCT CHANGES.  FAILURE TO DO THIS CAUSES THE BOLT-ON CODE TO */
/* BE COMBINED WITH STANDARD PRODUCT AND RESULTS IN PATCH DELIVERY FAILURES.*/
/*                                                                          */
/* -----  W A R N I N G  -----  W A R N I N G  -----  W A R N I N G  -----  */

/* DISPLAY TITLE */
{mfdtitle.i "b+ "}

define variable mfcrecid as recid no-undo.

{rspmform.i}

view frame mfrspm-a.

for first mfc_ctrl where
      mfc_field = "enable_shipping_schedules" and
      mfc_seq = 4  and
      mfc_module = "ADG"
      no-lock:
end.

if available mfc_ctrl then
   for first rsc_ctrl exclusive-lock:
   end.
if available rsc_ctrl then
   rsc_active = mfc_logical.

main-loop:
repeat with frame mfrspm-a:

   for first rsc_ctrl no-lock:
   end.

   if not available rsc_ctrl then do:
      create rsc_ctrl.
      assign
         rsc_active        = yes
         rsc_gen_ship      = yes
         rsc_auto_update   = no
         rsc_zero_req      = no
         rsc__qadl01       = no
         rsc_firm_days     = 0
         rsc_ship_days     = 0
         rsc_ship_weeks    = 0
         rsc_ship_months   = 0
         rsc_fab_days      = 0
         rsc_raw_days      = 0.

      if recid(rsc_ctrl) = -1 then.
   end.

   /* MFC_ctrl flag will be used to decide whether ship schedule
   * functionality is available. Once ship schedule becomes part of
   * std MFG/PRO, rsc_active would be used instead. We
   * maintain the two flag in sync by changing
   * mfc_ctrl whenever rsc_active changes. */

   for first mfc_ctrl where
         mfc_field = "enable_shipping_schedules" and
         mfc_seq = 4  and
         mfc_module = "ADG"
         no-lock:
   end.
   if not available mfc_ctrl then do:
      create mfc_ctrl.
      assign
         mfc_field = "enable_shipping_schedules"
         mfc_seq = 4
         mfc_module = "ADG"
         mfc_logical = rsc_active
         mfc_type = "l"
         mfcrecid = recid(mfc_ctrl).

      mfc_label =  getTermLabel("ENABLE_SHIPPING_SCHEDULES",24).

   end.
   else
      mfcrecid = recid(mfc_ctrl).

   for first rsc_ctrl exclusive-lock:
   end.

   display
      rsc_active
      rsc_gen_ship
      rsc_auto_update
      rsc_zero_req
      rsc__qadl01
      rsc_firm_days
      rsc_ship_days
      rsc_ship_weeks
      rsc_ship_months
      rsc_fab_days
      rsc_raw_days.

   update
      rsc_active
      rsc_gen_ship
      rsc_auto_update
      rsc_zero_req
      rsc__qadl01
      rsc_firm_days
      rsc_ship_days
      rsc_ship_weeks
      rsc_ship_months
      rsc_fab_days
      rsc_raw_days.

   find mfc_ctrl where recid(mfc_ctrl) = mfcrecid exclusive-lock.
   mfc_logical = rsc_active.

   if rsc_ship_weeks = 0 and
      rsc_ship_months = 0
   then do:
      {pxmsg.i &MSGNUM=4380 &ERRORLEVEL=3} /* WEEKS/MONTHS CANNOT BE ZERO */
      next-prompt rsc_ship_weeks with frame mfrspm-a.
      undo, retry.
   end.

   if rsc_ship_weeks = 0 then do:
      {pxmsg.i &MSGNUM=4369 &ERRORLEVEL=2} /* PLANNING WEEKS ENTERED AS 0 */
   end.

   if rsc_ship_months = 0 then do:
      {pxmsg.i &MSGNUM=4370 &ERRORLEVEL=2} /* PLANNING MONTHS ENTERED AS 0 */
   end. /* END OF IF l_vd_pln_sch  */

   if rsc_gen_ship and rsc_ship_days = 0 then do:
      /* SCHEDULE DAYS CANNOT BE 0 WHEN GENERATING SHIPPING SCHEDULES. */
      {pxmsg.i &MSGNUM=4371 &ERRORLEVEL=3}
      next-prompt rsc_ship_days with frame mfrspm-a.
      undo, retry.
   end. /* END OF IF rsc_gen_ship and rsc_ship_days */

   /* IT IS ASSUMED HERE THAT THERE ARE 30 DAYS IN A MONTH */
   if rsc_ship_days > rsc_ship_weeks * 7 + rsc_ship_months * 30
   then do:
      /* Shipping Schedule Days > Planning Schedule Weeks
      +  Planning Schedule Months. */
      {pxmsg.i &MSGNUM=4375 &ERRORLEVEL=2}
   end.

end. /* END OF MAINLOOP */

status input.
